import { Example } from '~/server/models/example.model';
import { createExampleSchema } from '~/server/schemas/example.schema';
import { validateBody } from '~/server/utils/validation.server';

export default defineEventHandler(async (event) => {
  // 使用 Zod 校验请求体数据
  const validatedData = await validateBody(event, createExampleSchema);

  // 创建数据并设置201状态码
  const example = await Example.create(validatedData);

  // 直接返回数据，响应包装由中间件处理
  return wrapResponse(event, example);
});
